//package com.douqu.game.main.platform;
//
//import com.alibaba.fastjson.JSONObject;
//import com.bean.core.util.HttpJsonUtils;
//import com.douqu.game.core.entity.sprite.Player;
//import com.douqu.game.core.factory.ConfigFactory;
//import com.douqu.game.core.protobuf.SGCommonProto;
//import com.douqu.game.core.util.Utils;
//import com.douqu.game.main.service.PlayerService;
//import org.apache.log4j.Logger;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Author : Bean
// * 2017-06-22 14:19
// */
//@Component
//public class XiaomiImpl implements PlatformSDK {
//
//    Logger logger = Logger.getLogger(this.getClass());
//
//    @Autowired
//    private PlayerService playerService;
//
//    @Override
//    public Player login(String account, String password, String ip)
//    {
//        try {
//            Map<String,String> params = new HashMap<>();
//            params.put("appId", ConfigFactory.XIAOMI_APP_ID);
//            params.put("session", password);
//            params.put("uid", account);
//            String paramStr = Utils.createLinkString(params);
//            params.put("signature", HmacSHA1Encryption.HmacSHA1Encrypt(paramStr, ConfigFactory.XIAOMI_APP_SECRET));
//
//            JSONObject result = HttpJsonUtils.httpGet(ConfigFactory.XIAOMI_VERIFY_URL + "?" + Utils.createLinkString(params));
//            logger.debug("小米验证结果："+ result);
//            if(result.getInteger("errcode")== 200)
//            {
//                //验证成功
//                account = Utils.createAccount(account, SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_XIAOMI);
//                Player player = playerService.getPlayerByAccount(account);
//                if(player == null)
//                {
//                    player = new Player();
//                }
//                return player;
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return null;
//    }
//}
